import requests  # 导入requests库，用于进行HTTP请求

def modular_pow(base, exponent, modulus):
    """ 使用迭代方法进行模块化指数运算 """
    result = 1
    base = base % modulus
    while exponent > 0:
        if exponent % 2:
            result = (result * base) % modulus
        exponent >>= 1
        base = (base * base) % modulus
    return result

answer = ''  # 初始化答案字符串

# 获取问题数据的JSON响应
get_html = requests.get("http://183.175.12.27:8002/step_04")
questions = get_html.json()['questions']

# 构造答案字符串
for i in eval(questions):
    answer += str(modular_pow(i[0], i[1], i[2])) + ','

param = {'ans': answer[:-1]}  # 构造参数，去除最后一个逗号
get_html = requests.get("http://183.175.12.27:8002/step_04", params=param)  # 发送带有答案参数的GET请求

print(get_html.text)  # 打印响应结果
